function sourceSpaceClassification(subject, foi, condition)
    
	eval(['load ', subject.subjectDir, '/', subject.subjID, '_', condition, '_data.mat data;']);
	
	%% calculate cross spectral density matrix
	cfg = [];
	cfg.method    = 'mtmfft';
	cfg.output    = 'powandcsd';
	cfg.tapsmofrq =  ones(1,size(cfg.foi,2)); % 4;
	cfg.foilim    = [min(foi) max(foi)];
	dataFreq 	  = ft_freqanalysis(cfg, data);
	
	%% create forward model and lead field
	% Could maybe use cfg.template to use a template to debug
	
	% segment T1 into skull, brain and csf
	cfg = [];
	cfg.write      = 'no';
	cfg.coordsys   = 'ctf';
	segmentedMRI   = ft_volumesegment(cfg, ft_read_mri(subject.MRI)); %requires SPM (should be in fieldtrip folder)    
	
	% prepare head model from segmented MRI
	cfg = [];
	vol = ft_prepare_singleshell(cfg, segmentedMRI);
    
	% create grid and calculate lead field matrix (forward model) for each grid point
	cfg                 = [];
	cfg.grad            = dataFreq.grad;	
	cfg.vol             = vol;
	cfg.reducerank      = 2;
	cfg.normalize		= 'yes'; %When not contrasting, normalize the lead field to control against power bias towards center of the head
	cfg.channel         = subject.MEGChannel;
	cfg.grid.resolution = 1;   % use a 3-D grid with a 1 cm resolution
	[grid] = ft_prepare_leadfield(cfg);
	
	%% scanning brain volume
	% time domain data works in another way (the data we work with here is freq instead of time domain; requires timelockanaylysis ipv freqAnalysis)
	
	% frequency data
	cfg              = []; 
	cfg.channel		 = subject.MEGChannels;
	% cfg.frequency    = foi; %has to be a single number
	cfg.method       = 'dics';
	cfg.projectnoise = 'yes';
	cfg.grid         = grid; 
	cfg.vol          = vol;
	cfg.lambda       = 0;
	cfg.singletrial	 = 'yes'; % leadfield over all trials, apply to single trials. Alternative cfg.rawtrial: filter from single trial, apply to single trial
	cfg.keeptrials   = 'yes';
	sourceFreq  	 = ft_sourceanalysis(cfg, dataFreq );
	
	%% plot the results - does that make sense in this case?
	% use ft_source_interpolate to align functional data and MRI; ft_sourceplot to plot the functional data on top of that MRI
	
	%% feed beamforming results in classifier
    
end